package com.zhuojy.equity.mall.admin.web.controller.message;

import com.zhuojy.equity.mall.admin.common.entity.bo.TPositionMessageBO;
import com.zhuojy.equity.mall.admin.common.entity.po.TInterviewRoundPO;
import com.zhuojy.equity.mall.admin.common.entity.po.TPositionMessagePO;
import com.zhuojy.equity.mall.admin.common.entity.vo.TPositionMessageVO;
import com.zhuojy.equity.mall.admin.common.pojo.JsonResult;
import com.zhuojy.equity.mall.admin.service.message.TPositionMessageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * @Author:LYL
 * @Date 2024/4/9 19:49
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("TPositionMessage")
@Api(tags = "职位设置模块")
public class TPositionMessageController {
    @Autowired
    private TPositionMessageService tPositionMessageService;

    @ApiOperation(value = "职位添加 三表添加", httpMethod = "POST", notes = "职位添加")
    @RequestMapping("addPositionMessage")
    public JsonResult addExpenseAccount(@RequestBody TPositionMessageBO tPositionMessageBO) {

        try {
            tPositionMessageService.addPositionMessage(tPositionMessageBO);
            return JsonResult.success(200, "添加成功！");
        } catch (Exception e) {
            e.printStackTrace();
            return JsonResult.success(444, "添加失败！");
        }
    }
    @ApiOperation(value = "部门设置招聘列表，分页查询", httpMethod = "POST", notes = "部门设置招聘列表分页查询")
    @RequestMapping("findPositionMessageFenYe")
    public JsonResult findPositionMessageFenYe(@RequestBody TPositionMessageVO tPositionMessageVO, @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
        return tPositionMessageService.findPositionMessageFenYe(tPositionMessageVO, pageNum, pageSize);
    }
    @ApiOperation(value = "招聘状态修改", httpMethod = "POST", notes = "招聘状态修改")
    @RequestMapping("updateStatusById")
    public JsonResult updateStatusById(@RequestBody TPositionMessageVO tPositionMessageVO) {

        try {
            tPositionMessageService.updateStatusById(tPositionMessageVO);
            return JsonResult.success(200, "修改成功！");
        } catch (Exception e) {
            e.printStackTrace();
            return JsonResult.success(444, "修改失败！");
        }
    }
    @ApiOperation(value = "招聘删除", httpMethod = "POST", notes = "招聘删除")
    @RequestMapping("delPositionMessageById")
    public JsonResult delPositionMessageById(Long id) {
        try {
            tPositionMessageService.delPositionMessageById(id);
            return JsonResult.success(200, "删除成功！");
        } catch (Exception e) {
            e.printStackTrace();
            return JsonResult.success(444, "删除失败！");
        }
    }
    @ApiOperation(value = "招聘回显", httpMethod = "POST", notes = "招聘回显")
    @RequestMapping("findPositionMessageById")
    public TPositionMessageVO findPositionMessageById(Long id){
        return tPositionMessageService.findPositionMessageById(id);
    }

    @ApiOperation(value = "会议室回显", httpMethod = "POST", notes = "会议室回显")
    @RequestMapping("findInterviewRound")
    public List<TInterviewRoundPO> findInterviewRound(Long id){
        return tPositionMessageService.findInterviewRound(id);
    }
    @ApiOperation(value = "招聘修改", httpMethod = "POST", notes = "招聘修改")
    @RequestMapping("updateTPositionMessage")
    public JsonResult updateTPositionMessage(@RequestBody TPositionMessageVO tPositionMessageVO) {
        try {
            tPositionMessageService.updateTPositionMessage(tPositionMessageVO);
            return JsonResult.success(200, "修改成功！");
        } catch (Exception e) {
            e.printStackTrace();
            return JsonResult.success(444, "修改失败！");
        }
    }
    @ApiOperation(value = "审批表多表导出", httpMethod = "POST", notes = "审批表多表导出")
    @RequestMapping(value = "getPositionMessageEntity", produces = MediaType.APPLICATION_JSON_VALUE)
    public boolean getPositionMessageEntity(HttpServletResponse response){
        tPositionMessageService.getPositionMessageEntity(response);
        return true;
    }

    @ApiOperation(value = "动态下拉框", httpMethod = "POST", notes = "动态下拉框")
    @RequestMapping("findPMessageAll")
    List<TPositionMessageVO> findPMessageAll(){
        return tPositionMessageService.findPMessageAll();
    }
}
